<?php
namespace Home\Controller;
use Think\Controller;
class GuahaoController extends Controller {
    public function index(){
        $pZjname = I('zj_name' , '','htmlspecialchars');
        if(IS_POST){
            $pRecommend = I('recommend' , '','int');  
            $pYYname = I('yy_name' , '','htmlspecialchars');  
            $pVisitingdate = I('visiting_date' , '','htmlspecialchars');  
            $pIllness = I('illness' , '','htmlspecialchars');  
            $pContact = I('contact' , '','htmlspecialchars');  
            $pPhone = I('phone' , '','int');  
            $pAddress = I('address' , '','htmlspecialchars');  
            $pCode = I('code' , '','trim');  

            if(empty($pCode)){
                $this->error('验证码不能为空'); 
            }

            if (!check_verify($pCode)) {
                $this->error('验证码不正确');
            }
            if(empty($pRecommend) && empty($pZjname)){
                $this->error('请填写专家'); 
            }
            if(empty($pContact)){
                $this->error('联系人不能为空'); 
            }
            if(empty($pPhone)){
                $this->error('手机号不能为空'); 
            }
            if(empty($pAddress)){
                $this->error('地址不能为空'); 
            }

            $tM = M('guahao');
            unset($_POST['code']);
            if(!$tM->add($_POST)){
                $this->error('提交失败'); 
            }
            $this->success('提交预约成功');
            exit;

        }

        $this->assign('tZjname' , $pZjname);
        $this->display();
    }

    public function verify(){
        $Verify = new \Think\Verify();
        $Verify->fontSize = 30;
        $Verify->length = 5;
        $Verify->useNoise = false;
        $Verify->entry();
    }
}
